//
//  CardView.m
//  YSLDraggingCardContainerDemo
//
//  Created by yamaguchi on 2015/11/09.
//  Copyright © 2015年 h.yamaguchi. All rights reserved.
//

#import "CardView.h"

@implementation CardView

- (instancetype)init {
    self = [super init];
    if (self) {
        [self setup];
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self setup];
    }
    return self;
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    if (self) {
        [self setup];
    }
    return self;
}

- (void)setup
{
    
    _backImageView = [[UIImageView alloc] initWithFrame:self.bounds];
    [self addSubview:_backImageView];
    
    _imageView = [[UIImageView alloc]init];
    _imageView.backgroundColor = [UIColor orangeColor];
    
    _imageView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height * 0.7);
    [_backImageView addSubview:_imageView];
    
    
    UIView *view = [[UIView alloc] init];
    view.frame = _imageView.bounds;
    view.backgroundColor = [UIColor colorWithWhite:0.000 alpha:0.105];
    [self addSubview:view];
    
    self.kindLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, _imageView.frame.size.width, 30)];
    _kindLabel.backgroundColor = [UIColor clearColor];
    _kindLabel.textColor = [UIColor whiteColor];
    _kindLabel.font = [UIFont fontWithName:@"FZLTZCHJW--GB1-0" size:13];
    _kindLabel.textAlignment = NSTextAlignmentCenter;
    _kindLabel.center =  self.backImageView.center;
    [view addSubview:_kindLabel];
    
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, _kindLabel.frame.origin.y - 50, _imageView.frame.size.width, 40)];
    _titleLabel.backgroundColor = [UIColor clearColor];
    _titleLabel.textColor = [UIColor whiteColor];
    _titleLabel.font = [UIFont fontWithName:@"FZLTZCHJW--GB1-0" size:16];
    _titleLabel.textAlignment = NSTextAlignmentCenter;
    [view addSubview:_titleLabel];
    
  
    
    
    
    UIBezierPath *maskPath;
    maskPath = [UIBezierPath bezierPathWithRoundedRect:_imageView.bounds
                                     byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight)
                                           cornerRadii:CGSizeMake(7.0, 7.0)];
    
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = _imageView.bounds;
    maskLayer.path = maskPath.CGPath;
    _imageView.layer.mask = maskLayer;
    
    _selectedView = [[UIView alloc]init];
    _selectedView.frame = _imageView.frame;
    _selectedView.backgroundColor = [UIColor clearColor];
    _selectedView.alpha = 0.0;
    [_imageView addSubview:_selectedView];
    
    _label = [[UILabel alloc]init];
    _label.backgroundColor = [UIColor clearColor];
    _label.frame = CGRectMake(10, self.frame.size.height * 0.7, self.frame.size.width - 20, self.frame.size.height * 0.3);
    _label.font = [UIFont fontWithName:@"FZLTXIHJW--GB1-0" size:11];
    _label.numberOfLines = 0;
    _label.backgroundColor = [UIColor clearColor];
    _label.textColor = [UIColor whiteColor];
    [_backImageView addSubview:_label];
    
    self.numberLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 7, _label.frame.size.width, 30)];
    _numberLabel.backgroundColor = [UIColor clearColor];
    _numberLabel.textColor = [UIColor blackColor];
    _numberLabel.font = [UIFont fontWithName:@"Lobster 1.4" size:14];
    _numberLabel.textAlignment = NSTextAlignmentCenter;
    [_label addSubview:_numberLabel];
    
    
    
}

@end
